package site.isscloud.jt809;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

public class LogoutRequest {
    private String platformId;
    
    public LogoutRequest(String platformId) {
        this.platformId = platformId;
    }
    
    public LogoutRequest(byte[] bytes) {
        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        byte[] platformIdBytes = new byte[11];
        bais.read(platformIdBytes, 0, 11);
        this.platformId = new String(platformIdBytes).trim();
    }
    
    public byte[] toByteArray() {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] platformIdBytes = new byte[11];
        byte[] srcBytes = platformId.getBytes();
        System.arraycopy(srcBytes, 0, platformIdBytes, 0, Math.min(srcBytes.length, 11));
        baos.write(platformIdBytes, 0, 11);
        return baos.toByteArray();
    }
    
    public String getPlatformId() {
        return platformId;
    }
    
    @Override
    public String toString() {
        return "LogoutRequest{platformId='" + platformId + "'}";
    }
}
